<?php

require_once('../simpletest/autorun.php');
require_once('../../system/components/DocumentComponent.php');

/**
 * TestOfDocumentComponent
 *
 * @author Pavel Egorov {@link mailto:pavel@egorov.ru pavel@egorov.ru}
 * @version 0.0.1 * $Revision$
 * @copyright Copyright (c) 2011, Pavel Egorov
 */
class TestOfDocumentComponent extends UnitTestCase {

    function testIfDocumentComponentNOTThrowsExceptionIfNameContainsBackSlashCharcters() {
        // Setup

        // Test
        try{
            $documentComponent = new system\components\DocumentComponent('\TestName');
        } catch (Exception $e){
            $documentComponent = NULL;
        }

        // Verify
        $this->assertNotNull($documentComponent);
    }

    function testIfDocumentComponentNOTThrowsExceptionIfNameContainsAlfaCharcters() {
        // Setup

        // Test
        try{
            $documentComponent = new system\components\DocumentComponent('TestName');
        } catch (Exception $e){
            $documentComponent = NULL;
        }

        // Verify
        $this->assertNotNull($documentComponent);
    }

    function testIfDocumentComponentNOTThrowsExceptionIfNameContainsAlfaNumericCharcters() {
        // Setup

        // Test
        try{
            $documentComponent = new system\components\DocumentComponent('Test3Name');
        } catch (Exception $e){
            $documentComponent = NULL;
        }

        // Verify
        $this->assertNotNull($documentComponent);
    }

    function testIfDocumentComponentThrowsExceptionIfNameContainsAlfaNumericCharctersAndNumberGoesFirst() {
        // Setup

        // Test
        try{
            $documentComponent = new system\components\DocumentComponent('3Test3Name');
        } catch (Exception $e){
            $documentComponent = NULL;
        }

        // Verify
        $this->assertNull($documentComponent);
    }

    function testIfDocumentComponentNOTThrowsExceptionIfNameContainsAlfaNumericCharctersAndUnderline() {
        // Setup

        // Test
        try{
            $documentComponent = new system\components\DocumentComponent('_Test3_Name_');
        } catch (Exception $e){
            $documentComponent = NULL;
        }

        // Verify
        $this->assertNotNull($documentComponent);
    }
}
